﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BooksManagermentSystem
{
    public partial class StudentInfo_form : Form
    {
        public StudentInfo_form()
        {
            InitializeComponent();
        }

        private void StudentInfo_form_Load(object sender, EventArgs e)
        {
            string id = Tag.ToString();
            //学生信息
            string sql = $"select * from StuInfo where stuid={id}";
            DataRow dr = DBhelper.GetDataRow(sql);
            textBox1.Text = dr["stuid"].ToString();
            textBox2.Text = dr["stuname"].ToString();
            textBox3.Text = dr["grade"].ToString();
            textBox4.Text = dr["major"].ToString();
            textBox5.Text = dr["arrearage"].ToString();

            //借阅信息
            string sql1 = $"select bookname 借阅书籍,starttime 借书日期,endtime 还书日期,free 费用 from RetrieveBook a inner join BookInfo b on a.bookid = b.bookid where a.stuid = '{id}'";

            dataGridView1.DataSource = DBhelper.GetDataTable(sql1);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            UpdateStudentPwd_form form = new UpdateStudentPwd_form();
            form.Tag = this.Tag.ToString();
            form.StartPosition= FormStartPosition.CenterParent;
            form.ShowDialog();
        }
    }
}
